package com.fourth_groups.shopping121store.ui.cart;


import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentTransaction;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.fourth_groups.shopping121store.R;
import com.fourth_groups.shopping121store.ui.cart.fragment.CartAlreadyFragment;
import com.fourth_groups.shopping121store.ui.cart.fragment.HotSaleActivity_Cart;

/**
 * ----------Dragon be here!----------/
 * 　　　┏┓　　　┏┓
 * 　　┏┛┻━━━┛┻┓
 * 　　┃　　　　　　　┃
 * 　　┃　　　━　　　┃  创建人:余兵兵
 * 　　┃　┳┛　┗┳　┃  时间:Administrator on 2016/10/10
 * 　　┃　　　　　　　┃  备注:购物车
 * 　　┃　　　┻　　　┃
 * 　　┃　　　　　　　┃
 * 　　┗━┓　　　┏━┛
 * 　　　　┃　　　┃神兽保佑
 * 　　　　┃　　　┃代码无BUG！
 * 　　　　┃　　　┗━━━┓
 * 　　　　┃　　　　　　　┣┓
 * 　　　　┃　　　　　　　┏┛
 * 　　　　┗┓┓┏━┳┓┏┛
 * 　　　　　┃┫┫　┃┫┫
 * 　　　　　┗┻┛　┗┻┛
 * ━━━━━━神兽出没━━━━━━by:coder-pig
 */
public class CartFragment extends Fragment {


    private HotSaleActivity_Cart hotSaleActivity_cart;
    private CartAlreadyFragment cartAlreadyFragment;

    //    private ListView CartListView;
//    static List<GoodsDetailBean> goodsDetailsList=new ArrayList<>();
    public CartFragment() {
        // Required empty public constructors
    }
    private static CartFragment cartFragment;
    public  static Fragment setFragment(){
        if (cartFragment==null)
            synchronized (CartFragment.class){
                if (cartFragment==null){
                    cartFragment=new CartFragment();
                }
            }
        return cartFragment;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        return inflater.inflate(R.layout.fragment_cart, container, false);

    }

    @Override
    public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        initView();//初始化控件
//        loadData();//创建数据
//        jump();//跳转


        getActivity().getSupportFragmentManager().beginTransaction().add(R.id.fl_cart, cartAlreadyFragment).commit();


    }

    private void initView() {
        hotSaleActivity_cart = new HotSaleActivity_Cart();
        cartAlreadyFragment = new CartAlreadyFragment();
    }


    private void jump() {
        int i=2;
//      加载Fragment对象
        FragmentTransaction cartAlready = getActivity().getSupportFragmentManager().beginTransaction().add(R.id.fl_cart, cartAlreadyFragment);
        FragmentTransaction hotSele = getActivity().getSupportFragmentManager().beginTransaction().add(R.id.fl_cart, hotSaleActivity_cart);

        if(i==1){
            hotSele.commit();
        }
        if(i==2){
            cartAlready.commit();
        }


    }



}
